package com.iyunsir.lesson05;


import javax.swing.*;
import java.awt.*;

public class JPanelDemo extends JFrame {
    public JPanelDemo(){
        Container container= this.getContentPane();
        container.setLayout(new GridLayout(2,1,10,10)); //后面参数的意思,间距

        JPanel Panel1 = new JPanel(new GridLayout(1,3));
        JPanel Panel2 = new JPanel(new GridLayout(1,2));
        JPanel Panel3 = new JPanel(new GridLayout(2,1));
        JPanel Panel4 = new JPanel(new GridLayout(3,2));

        Panel1.add(new JButton("1"));
        Panel1.add(new JButton("1"));
        Panel1.add(new JButton("1"));
        Panel2.add(new JButton("2"));
        Panel2.add(new JButton("2"));
        Panel3.add(new JButton("3"));
        Panel3.add(new JButton("3"));
        Panel4.add(new JButton("4"));
        Panel4.add(new JButton("4"));
        Panel4.add(new JButton("4"));
        Panel4.add(new JButton("4"));

        container.add(Panel1);
        container.add(Panel2);
        container.add(Panel3);
        container.add(Panel4);


        this.setVisible(true);
        this.setSize(500,500);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new JPanelDemo();

    }
}
